<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        li {
            list-style: none;
        }
        a {
            text-decoration: none;
        }
        .nav ul {
            overflow: hidden;
        }
        .nav ul li {
            float: left;
            width: 60px;
            height: 30px;
            background-color: #000;
            color: blue;
            text-align: center;
            line-height: 30px;
            position: relative;
        }
        .nav ul li a {
            position: relative;
            z-index: 2;
        }
        .nav ul li span {
            width: 60px;
            height: 30px;
            position: absolute;
            top: 30px;
            left: 0;
            background-color: yellow;
            z-index: 1;
        }
    </style>
</head>
<body>
    <div class="nav">
        <ul>
            <li><a href="javascript:void(0)">导航1</a><span></span></li>
            <li><a href="javascript:void(0)">导航2</a><span></span></li>
            <li><a href="javascript:void(0)">导航3</a><span></span></li>
            <li><a href="javascript:void(0)">导航4</a><span></span></li>
            <li><a href="javascript:void(0)">导航5</a><span></span></li>
            <li><a href="javascript:void(0)">导航6</a><span></span></li>
            <li><a href="javascript:void(0)">导航7</a><span></span></li>
            <li><a href="javascript:void(0)">导航8</a><span></span></li>
            <li><a href="javascript:void(0)">导航9</a><span></span></li>
        </ul>
        <div class="music">
            <audio src="mp3/1.ogg"></audio>
            <audio src="mp3/3.ogg"></audio>
            <audio src="mp3/3.ogg"></audio>
            <audio src="mp3/1.ogg"></audio>
            <audio src="mp3/3.ogg"></audio>
            <audio src="mp3/1.ogg"></audio>
            <audio src="mp3/1.ogg"></audio>
            <audio src="mp3/1.ogg"></audio>
            <audio src="mp3/3.ogg"></audio>
        </div>
    </div>
</body>
<script src='../common.js'></script>
<script>
    ;(function(){
        //获取元素
        var liList = document.querySelectorAll('.nav ul li');
        var spanList = document.querySelectorAll('.nav ul li span');
        var audioList = document.querySelectorAll('.music audio');

        //注册事件
        for(var i = 0; i < liList.length; i++){
            liList[i].onmouseenter = liMouseenter
            liList[i].onmouseleave = liMouseleave
        }
        function liMouseenter(){
            for(var i = 0; i < spanList.length; i++) {
                if(this == liList[i]) {
                    animationAll(spanList[i],{top:0});
                    audioList[i].load();
                    audioList[i].play();
                }else {
                    animationAll(spanList[i],{top:30});
                }
            }
        }
        function liMouseleave(){
            animationAll(this.lastElementChild,{top:30});
        }

    }())
</script>
<script src='../jquery-1.12.4.js'></script>
<script>
    // $(function(){
    //     $('.nav ul li').on('mouseenter',function(){
    //         $(this).children('span').stop(true,false).animate({top:0}).end().siblings().children('span').stop(true,false).animate({top:30})
    //         $('.music audio').get($(this).index()).load()
    //         $('.music audio').get($(this).index()).play()
    //     })
    // })
</script>
</html>